package com.example.microinvestcommon.entity;
import com.example.microinvestcommon.util.BigDecimalUtil;
import com.example.microinvestcommon.util.SnowflakeIdGeneratorUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.math.BigInteger;
@Data
@NoArgsConstructor
@AllArgsConstructor
//实体化用户卖出股票表
public class SellStock {
    private Long sellId;
    private Long userId;
    private String stockSymbol;
    private BigDecimal sellPrice;
    private Integer quantity;
    private BigDecimal totalAmount;
    private BigDecimalUtil bigDecimalUtil;

    public SellStock(Long userId, String stockSymbol, BigDecimal sellPrice, Integer quantity, SnowflakeIdGeneratorUtil snowflakeIdGenerator){
        //计算totalAmount的double
        double totalAmountDouble = bigDecimalUtil.multiply(sellPrice.doubleValue(), quantity);
        //double转BigDecimal
        BigDecimal totalAmountDecimal = BigDecimal.valueOf(totalAmountDouble);
        this.sellId=snowflakeIdGenerator.nextId();
        this.userId=userId;
        this.stockSymbol=stockSymbol;
        this.sellPrice=sellPrice;
        this.quantity=quantity;
        this.totalAmount=totalAmountDecimal;

    }

}
